<!DOCTYPE html>
<html lang="zh-CN" xmlns="http://www.w3.org/1999/xhtml"
      xmlns:th="http://www.thymeleaf.org">
<head th:include="/common/inc::header"/>
<body>
<form class="layui-form" id="bdForm" style="margin-left: 5%">
    <input name="bdTeamId" id="bdTeamId" type="hidden"/>
    <br/>
    <button class="layui-btn" lay-submit lay-filter="addCodeBtn">发配兑换券</button>
</form>
<table class="layui-table" id="grid" lay-filter="grid">
</table>
<script th:replace="/common/inc::incJs"></script>
<script>
    var form = layui.form;
    var tableIns;
    var successCallback;
    var bdTeamId = getQueryString("bdTeamId");
    var username = getQueryString("username");
    $("#bdTeamId").val(bdTeamId);

    form.on('submit(addCodeBtn)', function () {
        openDialog({
            url: "/backend/security/bdTeamCode/detail?bdTeamId="+bdTeamId,
            area: ["80%", "95%"],
            title: ['' + username + '', 'color: #FF0000;']
        });
        return false;
    });


    $(function () {
        tableIns = createTable({
            url: '/backend/security/bdTeamCode/list?bdTeamId='+bdTeamId,
            cols: [[
                {field: 'remark', title: '兑换券备注', width: 250}
                , {
                    fixed: 'right',
                    title: '操作',
                    width: 200,
                    align: 'center',
                    toolbar: '#opbar'
                }
            ]]
        });

        layui.table.on('tool(grid)', function (obj) { //注：tool是工具条事件名，test是table原始容器的属性 lay-filter="对应的值"
            var data = obj.data; //获得当前行数据
            var layEvent = obj.event; //获得 lay-event 对应的值
            var tr = obj.tr; //获得当前行 tr 的DOM对象
            if (layEvent === 'codeLogInfo') {
                openDialog({
                    url: "/backend/security/bdTeamCode/codeLogInfo?bdTeamCodeId=" + data.id,
                    area: ["70%", "90%"],
                    title: ['' + data.remark + '', 'color: #FF0000;'],
                    btn: ""
                });
            }
        });
    });
</script>
<script type="text/html" id="opbar">
    <a class="layui-btn layui-btn-xs" lay-event="codeLogInfo">查看兑换券详情</a>
</script>
</body>
</html>